package cn.iocoder.yudao.module.nmkj.dal.mysql.tagarticle;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.tagarticle.TagArticleDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nmkj.controller.admin.tagarticle.vo.*;

/**
 * 标签文章 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface TagArticleMapper extends BaseMapperX<TagArticleDO> {

    default PageResult<TagArticleDO> selectPage(TagArticlePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TagArticleDO>()
                .eqIfPresent(TagArticleDO::getTitle, reqVO.getTitle())
                .eqIfPresent(TagArticleDO::getContent, reqVO.getContent())
                .betweenIfPresent(TagArticleDO::getArticleTime, reqVO.getArticleTime())
                .eqIfPresent(TagArticleDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(TagArticleDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TagArticleDO::getStatus));
    }

    default TagArticleDO selectAppOne(Long id) {
        TagArticleDO reqVO = new TagArticleDO();
        reqVO.setStatus(1);
        reqVO.setId(id);
        return selectOne(new LambdaQueryWrapperX<TagArticleDO>()
                .eqIfPresent(TagArticleDO::getId, reqVO.getId())
                .eqIfPresent(TagArticleDO::getStatus, reqVO.getStatus()));
    }

}